#!/usr/bin/env sh
# Convert QT layout to ruby, require rbuic4,
# this is only needed when modifying the GUI.
RBUIC4="rbuic4"
GOT_RBUIC4=$(which $RBUIC4)
if [ "$GOT_RBUIC4" = "" ]; then
	echo "ERROR: $RBUIC4 not found, please install it before running this script."
	exit 1
fi
echo "Converting QT layout..."
GUI_ELEMENTS="Popup Rules Menu AddApp AddRule"
IFS=" "
for i in $GUI_ELEMENTS; do
	echo "  Converting: \"$i\""
	cat "./UI/$i.ui" | sed 's/>MainWindow</>'$i'_MainWindow</' > ./UI/$i.tmp
	cp ./UI/$i.tmp ./UI/$i.ui
	$RBUIC4 "./UI/$i.ui" -o "./UI/$i.rb"
done
echo "Done"
exit 0